package com.shijie.service;

import com.shijie.domain.entity.UserAddress;
import com.shijie.domain.enums.EnumInterface;
import com.shijie.mapper.UserScoresMapper;
import com.shijie.domain.entity.UserScores;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.shijie.core.AbstractService;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/*
 *  @author: smart boy
 *  @date: 2018-08-06
 */
@Service
public class UserScoresService extends AbstractService<UserScores> {

	@Resource
	private UserScoresMapper userScoresMapper;

	public List<UserScores> getScoresForUser(UserScores qCondition) {
        Example condition = new Example(UserScores.class);
        Example.Criteria criteria = condition.createCriteria();
        criteria.andEqualTo("userId", qCondition.getUserId()).andNotEqualTo("status", EnumInterface.Status.INVALID.ordinal());
        if (qCondition.getDirect() != null) {
            criteria.andEqualTo("direct", qCondition.getDirect());
        }
        if (qCondition.getType() != null) {
            criteria.andEqualTo("type", qCondition.getType());
        }
        return userScoresMapper.selectByCondition(condition);
    }

}
